<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style>
        .layui-table-box{
            overflow: visible;
        }
        .layui-table-box{
            overflow: visible;
        }
        .layui-table-header{
            overflow: visible;
        }
        .layui-table-box{
            overflow: visible;
        }
        .layui-table-main{
            overflow: visible;
        }
    </style>
</head>
<body>
<div>
    <div id="searchParam">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="text" readonly class="layui-input" id="statisticsYear" placeholder="年份">
            </div>
            <div class="layui-input-inline layui-form">
                <select id="statisticsMonth">
                    <option value="0">全年</option>
                    <option value="01">一月</option>
                    <option value="02">二月</option>
                    <option value="03">三月</option>
                    <option value="04">四月</option>
                    <option value="05">五月</option>
                    <option value="06">六月</option>
                    <option value="07">七月</option>
                    <option value="08">八月</option>
                    <option value="09">九月</option>
                    <option value="10">十月</option>
                    <option value="11">十一月</option>
                    <option value="12">十二月</option>
                </select>
            </div>
            <div class="layui-input-inline ">
                <button class="layui-btn" onclick="search()" id="search">统计</button>
            </div>
        </div>

    </div>
<!--    <table class="layui-hide" id="jcjf_table" lay-filter="jcjf_table"></table>-->
    <table  id="jcjf_table" lay-filter="jcjf_table"></table>
    <div  id="jcjfxz_div" hidden>
    <table class="layui-hide" id="jcjfxz_table" lay-filter="jcjfxz_table" hidden></table>
    </div>
</div>
</body>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm">工作积分</button>
    </div>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script>
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var tableIns1;
    var tableJcJfXz;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var tree = layui.tree;
    var startTime = null;
    var endTime = null;

    var currentDate = new Date();
    var currentYear=currentDate.getFullYear();
    var endYear = currentYear+4;
    layui.config({
        base: '/'
    }).extend({
        eleTree: 'layui-ext/eleTree/eleTree',
        tableMerge: 'layui-ext/tableMerge/tableMerge'
    }).use(['table', 'laypage', 'layer', 'laydate', 'tree', 'eleTree','tableMerge'], function () {
        var eleTree = layui.eleTree;
        var tableMerge = layui.tableMerge;
        tableIns1 = table.render({
            elem: '#jcjf_table'
            , contentType: 'application/json'
            , headers: {"authorization": token}
            , where: {loadOrNOT:0}
            , url: '/statistics/jcjfStatistics' //数据接口
            , method: 'POST',title:'工作积分'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.length, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data //解析数据列表
                }
            }
            , cols: [
                [
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'swjgjc', title: '科室',merge: true,width: 150,align:'center'},
                    {field: 'swryxm', title: '人员',width: 150,align:'center',event:'clickSwryXz'},
                    {field: 'swryDm', title: '税务人员代码',hide:true},
                    {field: 'cbdf', title: '查补积分', width: 150,align:'center',event:'clickCbjfXz'},
                    {field: 'rkdf', title: '入库积分', width: 150,align:'center',event:'clickRkjfXz'},
                    // {field: 'zxdf', title: '时限积分', width: 200,align:'center',event:'clickSxjfXz'},
                    {field: 'otherJf', title: '其他积分', width: 150,align:'center',event:'clickOtherjfXz'},
                    {field: 'grhj', title: '个人积分', width: 200,align:'center',event:'clickGrjfXz'},
                    {field: 'ksjf', title: '科室积分',merge: true, width: 150,align:'center'}
                ]
            ]
            , toolbar: '#toolbar'
            ,done: function(res, curr, count){
                tableMerge.render(this)
            }
        });

        //下钻表格加载
        tableJcJfXz =  table.render({
            elem: '#jcjfxz_table'
            , contentType: 'application/json'
            , headers: {"authorization": token}
            , where: {loadOrNOT:0}
            , url: '/statistics/jcjfStatisticsXz' //数据接口
            , method: 'POST'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.length, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data //解析数据列表
                }
            }
            , cols: [
                [
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'jcajbh', title: '案件编号',width: 200,align:'center'},
                    {field: 'nsrsbh', title: '纳税人识别号',width: 200,align:'center'},
                    {field: 'nsrmc', title: '纳税人名称',width: 200,align:'center'},
                    {field: 'jcks', title: '检查科室',width: 170,align:'center'},
                    {field: 'swryxm', title: '检查人',width: 190,align:'center'},
                    {field: 'nd', title: '年度',width: 100,align:'center'},
                    {field: 'yf', title: '月份', width: 100,align:'center'},
                    {field: 'cbje', title: '查补金额', width: 130,align:'center'},
                    {field: 'rkje', title: '入库金额', width: 130,align:'center'},
                    {field: 'cbdf', title: '查补积分', width: 130,align:'center'},
                    {field: 'rkdf', title: '入库积分', width: 130,align:'center'}
                ]
            ]
            , toolbar: true
        });


        //工具条事件
        table.on('tool(jcjf_table)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            //clickCbjfXz  clickRkjfXz clickSxjfXz
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            tableJcJfXz.reload({
                where: { //设定异步数据接口的额外参数，任意设
                    statisticsYear: $("#statisticsYear").val(),
                    statisticsMonth: $("#statisticsMonth").val(),
                    swryDm:data.swryDm,
                    loadOrNOT:"1"
                }
            });
            layer.open({
                type : 1,
                skin : 'layui-layer-molv',
                title : "积分明细",
                area : [ '100%', '100%' ],
                shade : 0.8,
                shadeClose : true,
                content : jQuery("#jcjfxz_div"),
                btn : [ '取消' ],
            });
        });

        laydate.render({
            elem: '#statisticsYear',min:currentYear+'-01-01',max:endYear+'-12-31'
            , type: 'year', done: function (value, date, endDate) {
                if (value != null && value != undefined && value != "") {
                    startTime = value;
                } else {
                    startTime = null;
                }
            },value: '2023'
        });
    });

    //执行查询
    function search() {
        //这里以搜索为例
        tableIns1.reload({
            where: { //设定异步数据接口的额外参数，任意设
                statisticsYear: $("#statisticsYear").val(),
                statisticsMonth: $("#statisticsMonth").val(),
                loadOrNOT:"1"
            }
        });
    }
</script>
</html>